#include "HerzeleidPrecompiled.hxx"

#include "HerzeleidCoreDispatcher.hxx"
#include "HerzeleidPointerEventArgs.hxx"

using namespace HerzeleidUICoreNamespaceImpl;

PointerEventArgs::PointerEventArgs(  ) : 
	m_eModifiers( PointerEventArgs::Modifiers::None ),
	m_CurrentPoint() 
{

}

PointerEventArgs::PointerEventArgs( _In_  WindowMessageConst Msg ) : 
	m_eModifiers( PointerEventArgs::Modifiers::None ),
	m_CurrentPoint() 
{
	RetrievePointerData( Msg );
}

Void PointerEventArgs::RetrieveMouseData( _In_  WindowMessageConst Msg, _In_ UpdateKind Kind )
{
	if (IsFlagChecked(Msg.WParam, MK_CONTROL)) m_eModifiers |= Modifiers::Control;
	if (IsFlagChecked(Msg.WParam, MK_SHIFT)) m_eModifiers |= Modifiers::Shift;
	m_CurrentPoint.Configure( Msg, Kind );
}

Void PointerEventArgs::RetrievePointerData( _In_  WindowMessageConst Msg )
{
	auto PointerId = GET_POINTERID_WPARAM(Msg.WParam);
	POINTER_INFO PointerInfo; Standard::ZeroValue( &PointerInfo );
	if ( !GetPointerInfo(PointerId, &PointerInfo) ) 
	{ 
		m_CurrentPoint.Configure( Msg, nullptr );
	}
	else
	{
		if ( IsFlagChecked(PointerInfo.dwKeyStates, POINTER_MOD_CTRL) )	m_eModifiers |= Modifiers::Control;
		if ( IsFlagChecked(PointerInfo.dwKeyStates, POINTER_MOD_SHIFT) ) m_eModifiers |= Modifiers::Shift;
		m_CurrentPoint.Configure( Msg, &PointerInfo );
	}
}